# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=cpio
pkgver=2.13
pkgrel=3
pkgdesc="tool to copy files into or out of a cpio or tar archive"
url="https://www.gnu.org/software/cpio"
arch="all"
license="GPL-3.0-or-later"
checkdepends="autoconf"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.bz2::http://ftp.snt.utwente.nl/pub/software/gnu/cpio/cpio-$pkgver.tar.bz2
	CVE-2021-38185.patch
	CVE-2021-38185-2.patch
	CVE-2021-38185-3.patch
	gcc-10.patch
	"

# secfixes:
#   2.13-r2:
#     - CVE-2021-38185
#   2.13-r0:
#     - CVE-2015-1197
#     - CVE-2019-14866
#   2.12-r3:
#     - CVE-2016-2037


build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--enable-largefile \
		--disable-mt \
		--disable-rpath \
		--disable-nls
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	rm -f "$pkgdir"/usr/lib/charset.alias
	rm -f "$pkgdir"/usr/libexec/rmt # part of the tar pkg
	rm "$pkgdir"/usr/share/man/*/rmt.*
}

sha512sums="
459398e69f7f48201c04d1080218c50f75edcf114ffcbb236644ff6fcade5fcc566929bdab2ebe9be5314828d6902e43b348a8adf28351df978c8989590e93a3  cpio-2.13.tar.bz2
60a857a51ac5bc53ef04e54cf00d065ab4dcfb0d6ec2ef4a4910ed0d62b9a8cc3c595e4ccf6d54c5d3524efc8a34284df093b335c8379392ca318ab72707ea5d  CVE-2021-38185-2.patch
53271b11f4f379efd52f364026bac982c3908e5f6b9507a318535952ae8f78c494b5abdfbaaf9e771055aa0b04c83a6dd3e24290cb433e045fed790e9c4b8ff6  CVE-2021-38185-3.patch
7cc828a5933e7eb3bd4f4f82db8579c96d5e6e99dfd07da143c9eb445823727db02819d6b7f578c89008e7fd098138d372af45369e442ea2e42b0b9296d3d772  CVE-2021-38185.patch
c04e657c05ba93a03191666de93527be6b646eaa155043db7fd517e98f7a8ed61c281efb067c66f3c14f350b869866ca21c9634ce678a17c3a108c2a4ab87276  gcc-10.patch
"
